<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT">





  <link rel="alternate" href="/atom.xml" title="renhao" type="application/atom+xml">






<meta name="description" content="本文根据前端必会的Nginx入门视频教程学习，对所学进行记录。原始教程">
<meta property="og:type" content="article">
<meta property="og:title" content="nginx教程学习">
<meta property="og:url" content="https://huangrenhao.gitee.io/2019/10/07/nginx/index.html">
<meta property="og:site_name" content="renhao">
<meta property="og:description" content="本文根据前端必会的Nginx入门视频教程学习，对所学进行记录。原始教程">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2020-09-24T03:44:07.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="nginx教程学习">
<meta name="twitter:description" content="本文根据前端必会的Nginx入门视频教程学习，对所学进行记录。原始教程">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://huangrenhao.gitee.io/2019/10/07/nginx/">





  <title>nginx教程学习 | renhao</title>
  








<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-Hans">
  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">renhao</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://huangrenhao.gitee.io/2019/10/07/nginx/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="renhao">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="renhao">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">nginx教程学习</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-10-07T08:06:35+08:00">
                2019-10-07
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing">
                  <a href="/categories/nginx/" itemprop="url" rel="index">
                    <span itemprop="name">nginx</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2019/10/07/nginx/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/2019/10/07/nginx/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  2.3k
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  9
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>本文根据前端必会的Nginx入门视频教程学习，对所学进行记录。<a href="https://juejin.im/post/5bd7a6046fb9a05d2c43f8c7#heading-5" target="_blank" rel="noopener">原始教程</a><a id="more"></a></p>
<h3 id="初始Nginx"><a href="#初始Nginx" class="headerlink" title="初始Nginx"></a>初始Nginx</h3><p>官方介绍：Nginx是一款轻量级的HTTP服务器，采用事件驱动的异步非阻塞处理方式框架，这让其具有良好的IO性能，时常用于服务端的反向代理和负载均衡。</p>
<p><strong>Nginx的优点</strong></p>
<ul>
<li>支持海量高并发：采用IO多路复用epoll。官方测试Nginx能够支持5万并发链接，实际生产环境中可以支撑2-4万并发连接数。</li>
<li>内存消耗少：在主流的服务器中Nginx目前是内存消耗最小的了，比如用Nginx+PHP，在3万并发链接下，开启10个Nginx进程消耗150M内存。</li>
<li>免费使用可以商业化：Nginx为开源软件，采用的是2-clause BSD-like协议，可以免费使用，并且可以用于商业。</li>
<li>配置文件简单：网络和程序配置通俗易懂，即使非专业运维也能看懂。</li>
</ul>
<h3 id="Nginx基本配置文件详解"><a href="#Nginx基本配置文件详解" class="headerlink" title="Nginx基本配置文件详解"></a>Nginx基本配置文件详解</h3><p>可以通过<code>rpm -ql nginx</code>查看nginx的所有安装位置。</p>
<p><code>nginx.conf</code>文件：Nginx的总配置文件（搭建服务器时经常调整的文件）</p>
<pre><code>#运行用户，默认即是nginx，可以不进行设置
user  nginx;
#Nginx进程，一般设置为和CPU核数一样
worker_processes  1;   
#错误日志存放目录
error_log  /var/log/nginx/error.log warn;
#进程pid存放位置
pid        /var/run/nginx.pid;

events {
    worker_connections  1024; # 单个后台进程的最大并发数
}

http {
    include       /etc/nginx/mime.types;   #文件扩展名与类型映射表
    default_type  application/octet-stream;  #默认文件类型
    #设置日志模式
    log_format  main  &#39;$remote_addr - $remote_user [$time_local] &quot;$request&quot; &#39;
                      &#39;$status $body_bytes_sent &quot;$http_referer&quot; &#39;
                      &#39;&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;&#39;;

    access_log  /var/log/nginx/access.log  main;   #nginx访问日志存放位置

    sendfile        on;   #开启高效传输模式
    #tcp_nopush     on;    #减少网络报文段的数量

    keepalive_timeout  65;  #保持连接的时间，也叫超时时间

    #gzip  on;  #开启gzip压缩

    include /etc/nginx/conf.d/*.conf; #包含的子配置项位置和文件
</code></pre><p><code>default.conf</code>配置项：</p>
<pre><code>server {
    listen       80;   #配置监听端口，如果80端口已被占用则启动失败
    server_name  localhost;  //配置域名

    #charset koi8-r;     
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;     #服务默认启动目录
        index  index.html index.htm;    #默认访问文件
    }

    #error_page  404              /404.html;   # 配置404页面

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;   #错误状态码的显示页面，配置后需要重启
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache&#39;s document root
    # concurs with nginx&#39;s one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
</code></pre><p>从配置项中可以看出服务目录放在了<code>/usr/share/nginx/html</code>，<code>index.html</code>和<code>50x.html</code>都在这两个目录下。</p>
<h3 id="Nginx服务启动、停止、重启"><a href="#Nginx服务启动、停止、重启" class="headerlink" title="Nginx服务启动、停止、重启"></a>Nginx服务启动、停止、重启</h3><p>启动：默认情况下需要进行手动启动</p>
<ul>
<li>nginx直接启动：<code>nginx</code></li>
<li>systemctl启动：<code>systemctl start nginx.service</code></li>
</ul>
<p>停止：</p>
<ul>
<li>立即停止服务：<code>nginx -s stop</code>，无论进程是否在工作都直接停止进程</li>
<li>从容停止服务：<code>nginx -s quit</code>，需要进程完成当前工作后再停止</li>
<li>killall方法杀死进程：<code>killall nginx</code>，直接杀死进程（野蛮，一般在上面两条命令无效时使用）</li>
<li>systemctl停止：<code>systemctl stop nginx.service</code></li>
</ul>
<p>重启：<code>systemctl restart nginx.service</code></p>
<p>重新载入配置文件：<code>nginx -s reload</code>，重写编写或者修改nginx配置文件后的重新载入</p>
<h3 id="自定义错误页和访问控制"><a href="#自定义错误页和访问控制" class="headerlink" title="自定义错误页和访问控制"></a>自定义错误页和访问控制</h3><p>多错误指向一个页面：<code>error_page 500 502 503 504 /50x.html</code>，<code>error_page</code>用于自定义错误页面，这段代码表示当发生上述指定的任意一个错误的时候都用网站根目录下的<code>/50x.html</code>文件响应。</p>
<p>单独为错误置顶处理方式：<code>error_page 404 /404_error.html</code>，为<code>404</code>设置指定页面。</p>
<p>把错误码换成一个地址：<code>error_page 404 http://www.example.com</code>，也可以使用外部资源。</p>
<p>简单实现访问控制：只允许特定主机访问即控制IP访问，在<code>location</code>中进行配置。</p>
<pre><code>location / {
    deny xxx.xxx.xxx.xxx;
    allow xxx.xxx.xxx.xxx;
}
</code></pre><h3 id="Nginx访问权限"><a href="#Nginx访问权限" class="headerlink" title="Nginx访问权限"></a>Nginx访问权限</h3><p>指令优先级：在同一个块下的两个权限指令，先出现的设置会覆盖后出现的设置（也就是谁先触发谁起作用）。</p>
<pre><code># 表示只允许特定IP访问，其他IP禁止访问；如果将deny all移到allow之前所有IP都不允许访问。
location / {
    allow xxx.xxx.xxx.xxx;
    deny all;
}
</code></pre><p>复杂访问控制权限匹配：<code>=</code>表示精确匹配</p>
<pre><code># 网站下的img目录运行所有用户访问
location = /img {
    allow all;
}
# 网站下的admin目录禁止IP访问
location = /admin {
    deny all;
}
</code></pre><p>正则表达式设置访问权限：</p>
<pre><code># 禁止访问以php结尾的文件
location ~\.php$ {
    deny all;
}
</code></pre><h3 id="Nginx设置虚拟主机"><a href="#Nginx设置虚拟主机" class="headerlink" title="Nginx设置虚拟主机"></a>Nginx设置虚拟主机</h3><p>虚拟主机是指在一台物理主机服务器上划分出多个磁盘空间，每个磁盘空间都是一个虚拟主机，每台虚拟主机都可以对外提供Web服务，并且互不干扰。在外界看来，虚拟主机就是一台独立的服务器主机，这意味着用户能够利用虚拟主机把多个不同域名的网站部署在同一台服务器上，而不必再为建立一个网站单独购买一台服务器，既解决了维护服务器技术的难题，同时又极大地节省了服务器硬件成本和相关的维护费用。</p>
<ul>
<li><p>基于端口号配置虚拟主机</p>
<p>原理是Nginx监听多个端口，根据不同的端口号来区分不同的网站。可以配置在主文件<code>nginx.conf</code>中或者子配置文件<code>default.conf</code>中。</p>
<p>在配置文件中新增如下代码，就会有两个server，在浏览器中通过不同的端口访问这两个server。</p>
<pre><code>server {
    listen 8081;
    server_name localhost;
    root /usr/share/nginx/html/html8081;
    index index.html;
}
</code></pre></li>
<li><p>基于IP的虚拟主机</p>
<p>基于IP和基于端口的配置几乎一样只是把<code>server_name</code>选项配置成IP就可以了。</p>
<pre><code>server {
    listen 80;
    server_name xxx.xxx.xxx.xxx;
    root /usr/share/nginx/html/html80;
    index index.html;
}
</code></pre></li>
</ul>
<h3 id="Nginx使用域名设置虚拟主机"><a href="#Nginx使用域名设置虚拟主机" class="headerlink" title="Nginx使用域名设置虚拟主机"></a>Nginx使用域名设置虚拟主机</h3><p>将配置文件中的server中server_name改为域名即可。</p>
<h3 id="Nginx反向代理设置"><a href="#Nginx反向代理设置" class="headerlink" title="Nginx反向代理设置"></a>Nginx反向代理设置</h3><p>反向代理与通常所说的代理工具不同，通常所说的代理（正向代理，即翻墙工具VPN）代理的是客户端，通过代理服务器访问真实服务器的内容。反向代理代理的是服务器，客户端的请求都要先经过这个代理，具体访问哪一个真实服务器是由代理来控制（这里是Nginx）。可以通过其为多个服务器提供负载均衡、缓存等功能。</p>
<p>将<code>http://www.example1.com</code>反向代理到<code>http://www.example2.com</code>。</p>
<pre><code>server {
    listen 80;
    server_name http://www.example1.com;
    location / {
        proxy_pass http://www.example2.com; # 一般反向代理都是一个IP，域名也可以
    }
}
</code></pre><p>反向代理常见指令：</p>
<ul>
<li><p>proxy_set_header :在将客户端请求发送给后端服务器之前，更改来自客户端的请求头信息。</p>
</li>
<li><p>proxy_connect_timeout:配置Nginx与后端代理服务器尝试建立连接的超时时间。</p>
</li>
<li><p>proxy_read_timeout : 配置Nginx向后端服务器组发出read请求后，等待相应的超时时间。</p>
</li>
<li><p>proxy_send_timeout：配置Nginx向后端服务器组发出write请求后，等待相应的超时时间。</p>
</li>
<li><p>proxy_redirect :用于修改后端服务器返回的响应头中的Location和Refresh。</p>
</li>
</ul>
<h3 id="Nginx适配PC或移动设备"><a href="#Nginx适配PC或移动设备" class="headerlink" title="Nginx适配PC或移动设备"></a>Nginx适配PC或移动设备</h3><p>移动站点可以通过自适应方式设定，但无论是复杂性和易用性都不如分开编写好。Nginx可以通过内置变量<code>$http_user_agent</code>可以获取到请求客户端的userAgent（可以根据用户目前处于移动端还是pc端进而展示不同的页面给用户）。</p>
<p>修改配置文件：</p>
<pre><code>server {
    listen 80;
    server_name localhost;
    location / {
        # pc目录
        root /usr/share/nginx/pc;
        if ($http_user_agent ~* &#39;(Android|webOS|iPhone|iPod|BlackBerry)&#39;) {
            # mobile目录
            root /usr/share/nginx/mobile;
        }
        index index.html;
    }
}
</code></pre><h3 id="Nginx的Gzip压缩配置"><a href="#Nginx的Gzip压缩配置" class="headerlink" title="Nginx的Gzip压缩配置"></a>Nginx的Gzip压缩配置</h3><p>Nginx提供了专门的gzip模块，模块指令：</p>
<ul>
<li><p>gzip : 该指令用于开启或 关闭gzip模块。</p>
</li>
<li><p>gzip_buffers : 设置系统获取几个单位的缓存用于存储gzip的压缩结果数据流。</p>
</li>
<li><p>gzip_comp_level : gzip压缩比，压缩级别是1-9，1的压缩级别最低，9的压缩级别最高。压缩级别越高压缩率越大，压缩时间越长。</p>
</li>
<li><p>gzip_disable : 可以通过该指令对一些特定的User-Agent不使用压缩功能。</p>
</li>
<li><p>gzip_min_length:设置允许压缩的页面最小字节数，页面字节数从相应消息头的Content-length中进行获取。</p>
</li>
<li><p>gzip_http_version：识别HTTP协议版本，其值可以是1.1.或1.0.</p>
</li>
<li><p>gzip_proxied : 用于设置启用或禁用从代理服务器上收到相应内容gzip压缩。</p>
</li>
<li><p>gzip_vary : 用于在响应消息头中添加Vary：Accept-Encoding,使代理服务器根据请求头中的Accept-Encoding识别是否启用gzip压缩。</p>
</li>
</ul>
<p>配置gzip：</p>
<pre><code>http {
    ....
    gzip on; # 启用gzip模块
    gzip_types text/plain application/javascript text/css; # 对文本、JavaScript和css文件进行压缩输出
    ....
}
</code></pre>
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/10/05/read-test-tdd/" rel="next" title="【读书笔记】JavaScript TDD">
                <i class="fa fa-chevron-left"></i> 【读书笔记】JavaScript TDD
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/10/07/css3-new/" rel="prev" title="css3新特性与动画">
                css3新特性与动画 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">renhao</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">94</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">19</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#初始Nginx"><span class="nav-number">1.</span> <span class="nav-text">初始Nginx</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Nginx基本配置文件详解"><span class="nav-number">2.</span> <span class="nav-text">Nginx基本配置文件详解</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Nginx服务启动、停止、重启"><span class="nav-number">3.</span> <span class="nav-text">Nginx服务启动、停止、重启</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#自定义错误页和访问控制"><span class="nav-number">4.</span> <span class="nav-text">自定义错误页和访问控制</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Nginx访问权限"><span class="nav-number">5.</span> <span class="nav-text">Nginx访问权限</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Nginx设置虚拟主机"><span class="nav-number">6.</span> <span class="nav-text">Nginx设置虚拟主机</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Nginx使用域名设置虚拟主机"><span class="nav-number">7.</span> <span class="nav-text">Nginx使用域名设置虚拟主机</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Nginx反向代理设置"><span class="nav-number">8.</span> <span class="nav-text">Nginx反向代理设置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Nginx适配PC或移动设备"><span class="nav-number">9.</span> <span class="nav-text">Nginx适配PC或移动设备</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Nginx的Gzip压缩配置"><span class="nav-number">10.</span> <span class="nav-text">Nginx的Gzip压缩配置</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">renhao</span>

  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">265.9k</span>
  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: false,
        notify: false,
        appId: '2P1xqUWiCoNm14MH4yhURlJi-gzGzoHsz',
        appKey: 'uJN0uagHIVgXtBO1OuLV9Ban',
        placeholder: 'Just go go',
        avatar:'mm',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  





  

  

  

  
  

  

  

  

</body>
</html>
